#include "pch.h"
#include "type.h"

bool Data::operator==(Data d)
{
	if (d.type == NUMBER_DATA)
	{
		return v_num == d.v_num;
	}
	if (d.type == STRING_DATA)
	{
		return v_str == d.v_str;
	}
	if (d.type == OBJECT_DATA)
	{
		return v_object == d.v_object;
	}
	return false;
}

bool method_info::operator==(method_info m)
{
	return name == m.name;
}

bool object_info::operator==(object_info o)
{
	return name == o.name;
}

bool describe_info::operator==(describe_info d)
{
	return name == d.name && target == d.target;
}

object::object(object_info o_info)
{
	type = o_info;
	for (auto i : o_info.properties)
	{
		vars[i.name] = i.default_data;
	}
}

void object::init()
{
	for (argument arg : type.properties)
	{
		vars[arg.name] = arg.default_data;
	}
}

bool object::operator==(object o)
{
	if (type == o.type)
	{
		return true;
	}
	return false;
}


std::wostream& operator<<(std::wostream& os, object obj)
{
	os << obj.type.name << "{";
	for (auto var : obj.vars)
	{
		os << var.first << ":" << var.second << ",";
	}
	os << "}";
	return os;
}

std::wostream& operator<<(std::wostream& os, Data d)
{
	if (d.type == NUMBER_DATA)
	{
		os << d.v_num;
	}
	else if (d.type == STRING_DATA)
	{
		os << d.v_str;
	}
	else if (d.type == OBJECT_DATA)
	{
		os << d.v_object;
	}
	else {
		os << "None";
	}
	return os;
}